<h1>Manage Admins</h1>
<?php
		if(!@$acl['admin_create'] OR @$acl['admin_create']!='yes')
		{
				?>
				<p style="color:#ff0000;font-weight:bold;">You have not enough permission to create admin accounts!</p>
				<?php
		}
		else
		{
?>	
<fieldset style="border: 1px solid #dedede;">
<legend>Add admin</legend>	
<?php $this->load->helper('form'); echo form_open('', array('id'=>'main_form')) ?>			
<table class="greentable">
	<tr id="form-item_username">
			<td width="200">Username</td>
			<td><input style="width:175px" type="text" id="username" name="username" value="" /><p class="error_descr"></p></td>
	</tr>
	<tr id="form-item_password">
			<td width="200">Password</td>
			<td><input style="width:175px" type="password" id="password" name="password" value="" /><p class="error_descr"></p></td>
	</tr>
	<tr id="form-item_password2">
			<td width="200">Confirm password</td>
			<td><input style="width:175px" type="password" id="password2" name="password2" value="" /><p class="error_descr"></p></td>
	</tr>
	<tr id="form-item_email">
			<td width="200">E-mail (optional)</td>
			<td><input style="width:175px" type="text" id="email" name="email" value="" /><p class="error_descr"></p></td>
	</tr>
</table>
<p style="font-weight:bold;">(<a href="javascript:void(0);" onclick="jQuery('#perms').toggle('slow');">see permissions</a>)</p>


<fieldset id="perms" style="border: 1px solid #dedede;display:none;">
<legend>Permissions</legend>	
<table class="greentable">
	<tr>
			<td width="200">Edit user info</td>
			<td>
					<input type="radio" name="acl[user_edit]" value="yes" checked="checked"/> Yes
					<input type="radio" name="acl[user_edit]" value="no" /> No
			</td>
	</tr>
	<tr>
			<td width="200">Delete user record</td>
			<td>
				<input type="radio" name="acl[user_delete]" value="yes" checked="checked"/> Yes
				<input type="radio" name="acl[user_delete]" value="no" /> No
			</td>
	</tr>
	<tr>
			<td width="200">Export users</td>
			<td>
				<input type="radio" name="acl[user_export]" value="yes" checked="checked"/> Yes
				<input type="radio" name="acl[user_export]" value="no" /> No
			</td>
	</tr>
	<tr>
			<td width="200">Import users</td>
			<td>
				<input type="radio" name="acl[user_import]" value="yes" checked="checked"/> Yes
				<input type="radio" name="acl[user_import]" value="no" /> No
			</td>
	</tr>
	<tr>
			<td width="200">Send e-mail</td>
			<td>
				<input type="radio" name="acl[send_email]" value="yes" checked="checked"/> Yes
				<input type="radio" name="acl[send_email]" value="no" /> No
			</td>
	</tr>
	<tr>
			<td width="200">Edit settings</td>
			<td>
				<input type="radio" name="acl[settings_edit]" value="yes" checked="checked"/> Yes
				<input type="radio" name="acl[settings_edit]" value="no" /> No
			</td>
	</tr>
	<tr>
			<td width="200">Create admin</td>
			<td>
				<input type="radio" name="acl[admin_create]" value="yes" checked="checked"/> Yes
				<input type="radio" name="acl[admin_create]" value="no" /> No
			</td>
	</tr>
	<tr>
			<td width="200">Edit admin</td>
			<td>
				<input type="radio" name="acl[admin_edit]" value="yes" checked="checked"/> Yes
				<input type="radio" name="acl[admin_edit]" value="no" /> No
			</td>
	</tr>
	<tr>
			<td width="200">Delete admin</td>
			<td>
				<input type="radio" name="acl[admin_delete]" value="yes" checked="checked"/> Yes
				<input type="radio" name="acl[admin_delete]" value="no" /> No
			</td>
	</tr>
</table>
</fieldset>

<?php echo form_close() ?>
	<div style="text-align:center;">
		<table cellspacing="0" cellpadding="4">
		<tr>
				<td>
					<span id="save-stat" style="color:orange;font-weight:bold;display:none;"></span>
					<input type="submit" id="bt-save" value="Add" class="submit" />
				</td>
		</tr>
		</table>
	</div>
</fieldset>
<?php
		}
?>

<fieldset style="border: 1px solid #dedede;">
<legend>Admins</legend>	
<table class="greentable">
    <thead>
    <tr>
		<th>#</th>
		<th>Username</th>
		<th>E-mail</th>
        <th>Added</th>
		<th>&nbsp;</th>
    </tr>
    </thead>
    <tbody>
<?php
	foreach($admins as $admin){
?>
    <tr>
        <td><a name="admin-<?php echo $admin->id; ?>"></a><?php echo $admin->id; ?></td>
        <td><?php echo $admin->username; ?></td>
        <td><?php echo $admin->email; ?></td>
        <td><?php echo $admin->a_added ? date("d/m/Y h:i:s A T",$admin->a_added) : 'N/A'; ?></td>
		<td class="actions">
		<?php
			if(@$acl['admin_edit'] && @$acl['admin_edit']=='yes')
			{
		?>
				<a class="edit" title="Edit" href="<?=$base_url?>admin/edit_admin/id/<?php echo $admin->id; ?>">edit</a> | 
		<?php
			}
		?>
		
		<?php
			if(@$acl['admin_delete'] && @$acl['admin_delete']=='yes')
			{
		?>
			<a class="del" title="Delete" href="javascript:void(0);" onclick="GolderMarkets.AdminMgt.deleteAdmin('<?=$admin->id?>');">delete</a>
		<?php
			}
		?>
		</td>
	</tr>
<?php
	}
?>
	<?php
			if($admins->result_count()==0)
			{
	?>
	<tr><td colspan="9">No accounts found.</td></tr>
	<?php
			}
	?>
    </tbody>
</table>
</fieldset>

	<script src="<?php echo $base_url; ?>js/validation.js"></script>
		<script src="<?php echo $base_url; ?>js/admin_mgt.js"></script>
		<script language="javascript">
				
				jQuery(document).ready(function() {
						jQuery('#bt-save').click(function(event){
								GolderMarkets.AdminMgt.addAdmin();
						});
						jQuery('#edit-form').submit(function(){
								return GolderMarkets.AdminMgt.addAdmin();
						});
				});
	</script>

